home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Shareware / Programare / sharp / wwwSharp_setup.exe / {app} / Examples / Data access / HtmlWriter / index.hta < prev    next >
Text File  |  2003-12-04  |  3KB  |  106 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4.     <TITLE>www-Sharp.ClrHost data access example</TITLE>
  5.     <META http-equiv="Content-Type" content="text/html; charset=windows-1252">
  6.     <META name="GENERATOR" content="MSHTML 6.00.2800.1264">
  7.     <META http-equiv="MSThemeCompatible" content="Yes">
  8.     <HTA:APPLICATION
  9.         id="appDataAccess"
  10.         WINDOWSTATE="normal"
  11.         SYSMENU="yes"
  12.         SINGLEINSTANCE="no"
  13.         SHOWINTASKBAR="yes"
  14.         SELECTION="yes"
  15.         SCROLLFLAT="no"
  16.         SCROLL="no"
  17.         NAVIGABLE="yes"
  18.         MINIMIZEBUTTON="yes"
  19.         MAXIMIZEBUTTON="yes"
  20.         INNERBORDER="yes"
  21.         CONTEXTMENU="yes"
  22.         CAPTION="yes"
  23.         BORDERSTYLE="normal"
  24.         BORDER="thick"
  25.         APPLICATIONNAME="www-Sharp data access example"></HTA:APPLICATION>
  26.     <OBJECT id="DataAccess" classid="clsid:4CC2B254-F4C7-4F52-881E-C2E10B14E003">
  27.         <PARAM name="AssemblyName" value="DataAccess">
  28.         <PARAM name="TypeName" value="wwwSharp.ClrHost.Examples.DataAccess">
  29.     </OBJECT>
  30.     <LINK href="DataAccess.css" type="text/css" rel="stylesheet">
  31. <SCRIPT language="JScript">
  32. function Initialize()
  33. {
  34.     inputConnStr.value = "Provider=SQLOLEDB;Integrated Security=SSPI;Initial catalog=pubs;";
  35.     textSqlQuery.innerText = "SELECT * FROM authors";
  36.     
  37.     try
  38.     {
  39.         OnBtnShowTablesClick();
  40.     }
  41.     catch(e) {};
  42. }
  43.  
  44. function OnBtnExecuteClick()
  45. {
  46.     try
  47.     {
  48.         DataAccess.ConnectionString = inputConnStr.value;
  49.         DataAccess.SqlQuery = textSqlQuery.innerText;
  50.         divOutput.innerHTML = DataAccess.ConvertQueryToHtml();
  51.         selectTables.ondblclick = "OnSelectTablesDblClick()";
  52.     }
  53.     catch(e)
  54.     {
  55.         window.alert(e.description);
  56.     }
  57. }
  58.  
  59. function OnBtnSelectConnectionClick()
  60. {
  61.     var locator = new ActiveXObject("DataLinks");
  62.     var conn = locator.PromptNew();
  63.     if (conn != null) inputConnStr.value = conn.ConnectionString;
  64.     
  65.  
  66.     OnBtnShowTablesClick();
  67. }
  68.  
  69. function OnBtnShowTablesClick()
  70. {
  71.     selectTables.innerText = "";
  72.     DataAccess.ConnectionString = inputConnStr.value;
  73.     selectTables.outerHTML = 
  74.         "<SELECT id=\"selectTables\" onchange=\"OnSelectTablesDblClick()\"> " +            
  75.         DataAccess.GetTableNamesForSelect() +
  76.         "</SELECT>";
  77. }
  78.  
  79. function OnSelectTablesDblClick()
  80. {
  81.     var tblName = selectTables.value;
  82.     textSqlQuery.innerText = "SELECT * FROM [" + tblName + "]";
  83. }
  84. </SCRIPT>
  85. </HEAD>
  86. <BODY onload="Initialize()">
  87.     <BUTTON id="btnSelectConnection" onclick="OnBtnSelectConnectionClick()">Connection 
  88.         string:</BUTTON> 
  89.     <INPUT id="inputConnStr" size="75"> 
  90.     <BR>
  91.     <BUTTON id="btnShowTables" onclick="OnBtnShowTablesClick()">Show tables</BUTTON> 
  92.     <BR>
  93.     <LABEL for="textSqlQuery">Sql query:</LABEL> 
  94.     <SELECT id="selectTables" onchange="OnSelectTablesDblClick()"></SELECT> 
  95.     <BR>
  96.     <TEXTAREA id="textSqlQuery" rows="5" cols="50"></TEXTAREA> 
  97.     <BR>
  98.     <BUTTON id="btnExecute" onclick="OnBtnExecuteClick()">Execute query</BUTTON> 
  99.     <DIV id="divOutput"></DIV>
  100.     <DIV id="divFooter">
  101.         <P id="creator">Created with <A href="http://www-sharp.com/" target="_blank"><STRONG>
  102.             www-Sharp</STRONG></A>.</P>
  103.     </DIV>
  104. </BODY>
  105. </HTML>
  106.